/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


Ext.QuickTips.init();
var _pageSize = 20;

var fieldName = ['id', 'name', 'rate', 'pointType', 'pointType2', 'reportStatusCh', 'startStatusCh', 'isOffline', 'company', 'subCompany', 'planRate',
     'totalRunMin','aboveUpperLimitMin','underLowerLimitMin','upperLimitRate','lowerLimitRate','qualifiedMin','unqualifiedMin',"dateStr","rn"];
var fieldLabel = ['ID', '监测点名称', '合格率（%）', '监测点类型', '电网类型', '上报', '启用停用', '在线离线', '供电局', '部门分县局', '合格率指标（%）',
    '总运行时间(min)','超上限时间(min)','超下限时间(min)','超上限率','超下限率','合格时间(min)','不合格时间(min)'];

var loadServlet = '../../servlet/data/RsjLoad';
var theme = ' 电压日数据缺失告警';

var _title = currentOrgName + theme;

var now = new Date();

var checkboxSel = new Ext.grid.CheckboxSelectionModel();
var store;
function buildWindow() {

    store = new Ext.data.JsonStore({
        url: loadServlet,
        root: 'data',
        idProperty: 'rn',
        totalProperty: 'count',
        fields: fieldName,
        baseParams: {lock:lock,cmd:"general",have:1,dateFrom: now.add(Date.DAY,-7).format("Ymd"), dateTo: now.format("Ymd"), start: 0, limit: _pageSize}
        , autoLoad: true
    });

    var grid = new Ext.grid.GridPanel({
        title: _title,
        store: store,
        sm: checkboxSel,
        viewConfig: {
            forceFit: true
        },
        columns: [
            checkboxSel,
            {header: 'ID', sortable: true, dataIndex: 'id', hidden: true},
            {header: '供电局', width: 150, sortable: true, dataIndex: 'company'},
            {header: '部门分县局', width: 120, sortable: true, dataIndex: 'subCompany'},
            {header: '监测点名称', width: 180, sortable: true, dataIndex: 'name'},
            {header: '日期', width: 100, sortable: true, dataIndex: 'dateStr'},//          
            {header: '监测点类型', width: 80, sortable: true, dataIndex: 'pointType'},
            {header: '电网类型', width: 80, sortable: true, dataIndex: 'pointType2'},
            {header: '上报', width: 80, sortable: true, dataIndex: 'reportStatusCh'},
            {header: '启用停用', width: 80, sortable: true, dataIndex: 'startStatusCh'},
            {header: '在线离线', width: 80, sortable: true, dataIndex: 'isOffline'}
        ],
        
        loadMask: true,
        tbar: new Ext.Toolbar([
            pointTypeCombo,
            pointType2Combo,
            voltageLevelCombo,
            reportCombo,
            pointText,
            "-",
            {
                xtype: 'datefield',
                id: 'DateFrom',
                format: 'Y年m月d日',
                width: 150,
                value: now.add(Date.DAY, -7),
                listeners: {
                    select: function(c, date) {                        
                        store.baseParams.dateFrom = date.format("Ymd");
                    }
                }
            },            
            {
                text: "至", xtype: 'label'
            },
            {
                xtype: 'datefield',
                id: 'DateTo',
                format: 'Y年m月d日',
                width: 150,
                value: now,
                listeners: {
                    select: function(c, date) {                        
                        store.baseParams.dateTo = date.format("Ymd");
                    }
                }
            },                    
            {
                xtype: 'button',
                text: '搜索',
                iconCls: 'icon-search',
                width: 60,
                style: {marginLeft: '20px'},
                handler: function() {
                    store.reload();
                }
            }
        ]),
        bbar: new Ext.PagingToolbar({
            pageSize: _pageSize,
            store: store,
            displayInfo: true,
            displayMsg: '显示记录：{0} - {1}   总记录：{2}',
            emptyMsg: "目前没有" + theme + '信息'
        })
    });
    //grid.el.center();
    //store.load({params: {start: 0, limit: _pageSize}});

    var applicationUI = new Ext.Viewport({
        layout: "fit",
        items: [
            grid
        ]
    });
}
Ext.onReady(buildWindow);  